home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- import pydoc
- import sys
- import warnings
- from ZSI import TC
-
- def _x():
- pass
-
-
- try:
- _x.func_name = '_y'
- except:
- raise RuntimeError, 'use python-2.4 or later, cannot set function names in python "%s"' % sys.version
-
- del _x
-
- class pyclass_type(type):
-
- def __new__(cls, classname, bases, classdict):
- typecode = classdict.get('typecode')
- if len(bases) > 0:
- pass
- elif typecode.mixed:
- (get, set) = cls._pyclass_type__create_text_functions_from_what(typecode)
- if classdict.has_key(get.__name__):
- raise AttributeError, 'attribute %s previously defined.' % get.__name__
-
- if classdict.has_key(set.__name__):
- raise AttributeError, 'attribute %s previously defined.' % set.__name__
-
- classdict[get.__name__] = get
- classdict[set.__name__] = set
-
- for what in typecode.ofwhat:
- (get, set, new_func) = cls._pyclass_type__create_functions_from_what(what)
- if classdict.has_key(get.__name__):
- raise AttributeError, 'attribute %s previously defined.' % get.__name__
-
- classdict[get.__name__] = get
- if classdict.has_key(set.__name__):
- raise AttributeError, 'attribute %s previously defined.' % set.__name__
-
- classdict[set.__name__] = set
- if new_func is not None:
- if classdict.has_key(new_func.__name__):
- raise AttributeError, 'attribute %s previously defined.' % new_func.__name__
-
- classdict[new_func.__name__] = new_func
-
- pname = what.pname
- if pname is None and isinstance(what, TC.AnyElement):
- pname = 'any'
-
- pname = pname[0].upper() + pname[1:]
- classdict[pname] = property(get, set, None, 'property for element (%s,%s), minOccurs="%s" maxOccurs="%s" nillable="%s"' % (what.nspname, what.pname, what.minOccurs, what.maxOccurs, what.nillable))
-
- if hasattr(typecode, 'attribute_typecode_dict'):
- if not typecode.attribute_typecode_dict:
- pass
- attribute_typecode_dict = { }
- for key, what in attribute_typecode_dict.items():
- (get, set) = cls._pyclass_type__create_attr_functions_from_what(key, what)
- if classdict.has_key(get.__name__):
- raise AttributeError, 'attribute %s previously defined.' % get.__name__
-
- if classdict.has_key(set.__name__):
- raise AttributeError, 'attribute %s previously defined.' % set.__name__
-
- classdict[get.__name__] = get
- classdict[set.__name__] = set
-
-
- return type.__new__(cls, classname, bases, classdict)
-
-
- def __create_functions_from_what(what):
- if not callable(what) and getattr(what, 'pyclass', None) is None:
- new_func = None
- elif isinstance(what, TC.ComplexType) or isinstance(what, TC.Array):
-
- def new_func(self):
- return what.pyclass()
-
- elif not callable(what):
-
- def new_func(self, value):
- return what.pyclass(value)
-
- elif issubclass(what.klass, TC.ComplexType) or issubclass(what.klass, TC.Array):
-
- def new_func(self):
- p = what().pyclass
- if p is None:
- return None
-
- return p()
-
- else:
-
- def new_func(self, value = (None,)):
- p = what().pyclass
- if p is None:
- return None
-
- if value is None:
- return p()
-
- return p(value)
-
- if new_func is not None:
- new_func.__name__ = 'new_%s' % what.pname
-
- get.func_name = 'get_element_%s' % what.pname
- set.func_name = 'set_element_%s' % what.pname
- return (get, set, new_func)
-
- __create_functions_from_what = staticmethod(__create_functions_from_what)
-
- def __create_attr_functions_from_what(key, what):
-
- def get(self):
- 'returns attribute value for attribute %s, else None.\n ' % str(key)
- return getattr(self, what.attrs_aname, { }).get(key, None)
-
-
- def set(self, value):
- 'set value for attribute %s.\n value -- initialize value, immutable type\n ' % str(key)
- if not hasattr(self, what.attrs_aname):
- setattr(self, what.attrs_aname, { })
-
- getattr(self, what.attrs_aname)[key] = value
-
- if type(key) in (tuple, list):
- get.__name__ = 'get_attribute_%s' % key[1]
- set.__name__ = 'set_attribute_%s' % key[1]
- else:
- get.__name__ = 'get_attribute_%s' % key
- set.__name__ = 'set_attribute_%s' % key
- return (get, set)
-
- __create_attr_functions_from_what = staticmethod(__create_attr_functions_from_what)
-
- def __create_text_functions_from_what(what):
-
- def get(self):
- return getattr(self, what.mixed_aname, None)
-
- get.im_func = 'get_text'
-
- def set(self, value):
- setattr(self, what.mixed_aname, value)
-
- get.im_func = 'set_text'
- return (get, set)
-
- __create_text_functions_from_what = staticmethod(__create_text_functions_from_what)
-
-